package com.feng.leetcode;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author feng
 * @decrition
 * @date 2022/9/1823:42
 */
public class L1680 {
    public static void main(String[] args) {
        String date1 = "2019-06-29";
        String date2 = "2019-05-30";
        int i = daysBetweenDates(date1, date2);
        System.out.println(i);
    }

    public static int daysBetweenDates(String date1, String date2) {
        try {
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
            long time1 = simpleDateFormat.parse(date1).getTime();
            long time2 = simpleDateFormat.parse(date2).getTime();
            long l = time2 - time1;
            long day = l/ 1000/60/60/24;
            return Integer.valueOf(Math.abs(day) + "");
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return 0;
    }
}
